<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <link rel="stylesheet" href="http://www.petercorke.com/RVC/common/toolboxhelp.css">
    <title>M-File Help: distancexform</title>
  </head>
  <body>
  <table border="0" cellspacing="0" width="100%">
    <tr class="subheader">
      <td class="headertitle">M-File Help: distancexform</td>
      <td class="subheader-left"><a href="matlab:open distancexform">View code for distancexform</a></td>
    </tr>
  </table>
<h1>distancexform</h1><p><span class="helptopic">Distance transform</span></p><p>
<strong>d</strong> = <span style="color:red">distancexform</span>(<strong>im</strong>, <strong>options</strong>) is the distance transform of the binary
image <strong>im</strong>. The elements of <strong>d</strong> have a value equal to the shortest distance
from that element to a non-zero pixel in the input image <strong>im</strong>.

</p>
<p>
<strong>d</strong> = <span style="color:red">distancexform</span>(<strong>occgrid</strong>, <strong>goal</strong>, <strong>options</strong>) is the distance transform of
the occupancy grid <strong>occgrid</strong> with respect to the specified goal point <strong>goal</strong>
= [X,Y].  The cells of the grid have values of 0 for free space and 1 for
obstacle. The resulting matrix <strong>d</strong> has cells whose value is the shortest
distance to the goal from that cell, or NaN if the cell corresponds to an
obstacle (set to 1 in <strong>occgrid</strong>).

</p>
<p>
Options:

</p>
<table class="list">
  <tr><td style="white-space: nowrap;" class="col1"> 'euclidean'</td> <td>Use Euclidean (L2) distance metric (default)</td></tr>
  <tr><td style="white-space: nowrap;" class="col1"> 'cityblock'</td> <td>Use cityblock or Manhattan (L1) distance metric</td></tr>
  <tr><td style="white-space: nowrap;" class="col1">'show', D</td> <td>Show the iterations of the computation, with a delay of D seconds
between frames.</td></tr>
  <tr><td style="white-space: nowrap;" class="col1"> 'noipt'</td> <td>Don't use Image Processing Toolbox, even if available</td></tr>
  <tr><td style="white-space: nowrap;" class="col1"> 'novlfeat'</td> <td>Don't use VLFeat, even if available</td></tr>
  <tr><td style="white-space: nowrap;" class="col1"> 'nofast'</td> <td>Don't use IPT, VLFeat or imorph, even if available.</td></tr>
</table>
<h2>Notes</h2>
<ul>
  <li>For the first case Image Processing Toolbox (IPT) or VLFeat will be used if
available, searched for in that order.  They use a 2-pass rather than
iterative algorithm and are much faster.</li>
  <li>Options can be used to disable use of IPT or VLFeat.</li>
  <li>If IPT or VLFeat are not available, or disabled, then imorph is used.</li>
  <li>If IPT, VLFeat or imorph are not available a slower M-function is used.</li>
  <li>If the 'show' option is given then imorph is used.</li>
<ul>
  <li>Using imorph requires iteration and is slow.</li>
  <li>For the second case the Machine Vision Toolbox function imorph is required.</li>
  <li>imorph is a mex file and must be compiled.</li>
</ul>
  <li>The goal is given as [X,Y] not MATLAB [row,col] format.</li>
</ul>
<h2>See also</h2>
<p>
<a href="imorph.html">imorph</a>, <a href="DXform.html">DXform</a></p>
<hr>

<table border="0" width="100%" cellpadding="0" cellspacing="0">
  <tr class="subheader" valign="top"><td>&nbsp;</td></tr></table>
<p class="copy">&copy; 1990-2014 Peter Corke.</p>
</body></html>